<?php
$CI =& get_instance();
$CI->load->library('pagination');
$CI->load->model('Model_user', 'model_user');
$keyword = $this->input->post("keyword");
$limit = 10;
$total = $CI->model_user->browse_count($keyword,null,null);
$offset = 0;
$per_page = $this->uri->segment(2,0);
if($per_page < $total){
	$offset = $per_page;
}
$users = $CI->model_user->browse($keyword);
$config['base_url'] = site_url(array('c'=>'home', 'm'=>'search'));
$config['uri_segment'] = 2;
$config['total_rows'] = $total;
$config['per_page'] = $limit;
?>
<div>
	<table width="100%" cellpadding="0" cellspacing="1">	
	<thead>
		<tr>
			<th align="center">No.</th>
			<th>Store Name</th>
			<th><?=lang('address');?></th>
			<th><?=lang('homephone');?></th>
			<th><?=lang('fax');?></th>
			<th><?=lang('email');?></th>
			<th><?=lang('map');?></th>
		</tr>
	</thead>
	<tbody>
	<?php if(is_array($users)):?>
	<?php $i = 0;foreach($users as $item):$i++;?>
		<tr>
		<td align="center"><?=$i;?></td>
		<td><?=$item['company_name']?></td>
		<td><?=$item['address']?></td>
		<td><?=$item['home_phone']?></td>
		<td><?=$item['fax']?></td>
		<td><a href="mailto:<?=$item['email']?>" title="mailto"><?=$item['email']?></a></td>
		<td align="center">
			<a href="#" class="viewmap" title="View Map" rel="#map<?=$i;?>">View Map</a>
		</td>
		</tr>
	<?php endforeach;?>
	<?php endif;?>
	</tbody>
	</table>
	<div class="pagination"><?=$CI->pagination->create_links();?></div>
	<?php if(is_array($users)):?>
	<?php $i = 0;foreach($users as $item):$i++;?>
		<div id="map<?=$i?>" class="simple_overlay"><img src="<?=$item['google_map']?>" alt="Map"/></div>
	<?php endforeach;?>
	<?php endif;?>
</div>
<div class="clearfix"></div>
<script type="text/javascript">
$(function(){
	$(".viewmap").overlay({mask: {
		color: '#ebecff',
		loadSpeed: 200,
		opacity: 0.9
	}});
});
</script>